import request from '@/utils/request'

// 获取新的商品信息
export const getNewCartGoodsAPI = (skuId) => {
  return request({
    url: `/goods/stock/${skuId}`
  })
}

// 合并购物车
export const mergeLocalCartAPI = (data) => {
  return request({
    url: '/member/cart/merge',
    method: 'POST',
    data
  })
}

// 获取购物车列表
export const getCartListAPI = () => {
  return request({
    url: '/member/cart'
  })
}

// 线上加入购物车
export const insertCartAPI = (data) => {
  return request({
    url: '/member/cart',
    method: 'post',
    data
  })
}

// 线上购物车删除单个商品
export const deleteCartAPI = (ids) => {
  return request({
    url: '/member/cart',
    method: 'DELETE',
    data: {
      ids
    }
  })
}

// 线上购物车选中效果
export const updateCartAPI = (goods) => {
  return request({
    url: `/member/cart/${goods.skuId}`,
    method: 'PUT',
    data: goods
  })
}

// 线上购物车全选
export const checkAllCartAPI = ({ selected, ids }) => {
  return request({
    url: '/member/cart/selected',
    method: 'put',
    data: { selected, ids }
  })
}
